document.addEventListener('DOMContentLoaded',function (){
    // 提示框
    var newpma = document.querySelector('.newpwd');
    var celppma = document.querySelector('.celpwd');
    var tellma = document.querySelector('.telltip');
    var inputs = document.querySelectorAll('input');
    function ifpan(obj,length)
    {
        if(length>=8)
        {
            obj.style.display = 'none';
        }else {
            obj.style.display = 'block';
        }
    }
    inputs[0].addEventListener('focus', function (){
        if(this.value === '')
        {
            newpma.style.display = 'block';
        }
        ifpan(newpma,this.value.length);
    });
    inputs[0].addEventListener('blur', function (){
        ifpan(newpma,this.value.length);
    });
    inputs[1].addEventListener('focus', function (){
        if(this.value === '')
        {
            celppma.style.display = 'block';
        }
        ifpan(celppma,this.value.length);
    });
    inputs[1].addEventListener('blur', function (){
        ifpan(celppma,this.value.length);
        if(inputs[0].value !== this.value)
        {
            alert('密码不一致！请重新输入！');
            this.value = '';
        }
    });
    inputs[2].addEventListener('focus', function (){
        if(this.value === '')
        {
            tellma.style.display = 'block';
        }
        if(this.value.length===11)
        {
            tellma.style.display = 'none';
        }
        else  tellma.style.display = 'block';
    });
    inputs[2].addEventListener('blur', function (){
        if(this.value.length===11)
        {
            tellma.style.display = 'none';
        }
        else  tellma.style.display = 'block';
    });
    // 验证码定时器
    var code = document.querySelector('.code');
    var i=30;
    code.addEventListener('click',function (){
        var codetime = setInterval(function (){
            code.innerText = '剩下'+i+'s';
            i--;
            code.disabled = true;
            code.style.color = 'red';
            if(i<=0)
            {
                clearInterval(codetime);
                code.disabled = false;
                code.innerText = '验证码';
                i=30;
                code.style.color = '#333';
            }
        },1000);
    });
    // 确定与重置
    // var ok = document.querySelector('#ok');
    var reset = document.querySelector('.style_backred');
    reset.addEventListener('click', function (){
       for(var k in inputs)
       {
           inputs[k].value = '';
       }
    });
});